package com.jinzhi.oss.controller;

import com.jinzhi.jzweb.utils.ValuesUtil;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;

/**
 * -----BEGIN CERTIFICATE REQUEST-----
 * MIIC4TCCAckCAQAwgZsxCzAJBgNVBAYTAkNOMRIwEAYDVQQIDAlHdWFuZ0Rvbmcx
 * ETAPBgNVBAcMCFNoZW5aaGVuMRswGQYDVQQKDBLlvq7kv6HllYbmiLfns7vnu58x
 * MzAxBgNVBAsMKua5luWNl+mHkeiBjOS8n+S4muavjeWptOaKpOeQhuaciemZkOWF
 * rOWPuDETMBEGA1UEAwwKMTU3OTEyMDM4MTCCASIwDQYJKoZIhvcNAQEBBQADggEP
 * ADCCAQoCggEBAO/qS9fS7CFsGzF+eSl8S4SlX+KuI8Yl/+zEjd7S23U9LWBv6LeA
 * 6iefHIi3ByfgQrC9LlKnthLskBsEapBxBrme/SCEnufgWMX9ofCpS5/H+r+nR4c8
 * Oi5sLdgjemRpl9OfZEgD2LsR7hlflpf3aRczl2av4JIbk+BeV+tqjPUsqWL3G7dB
 * yBPcT0jAXoUvusjT7LDwIs4a3dOU7KsFK9N9ExK4pSd2cls0ZKs92NTB8+VSX7KW
 * nQ5CtOdgthBnUL0R6nh3vvLz7d8K12MPDcn9JaHPgovTnv1yg4aGeArngoC4pYiM
 * ivDMkMZ2P2rxPaHZEcT2PuVObg9SgJY9rO0CAwEAAaAAMA0GCSqGSIb3DQEBCwUA
 * A4IBAQAAskXM0Euc8XDhj7pJ3khPNbHXo33HdSAE1Pgj5/RFlO7MkDVS09eKb07/
 * 8qw6FXRCaFYezrh1WtIYWfetVrmZZzJzSj1DI0TmgCQZ9FM/+IrIuLivP+wPziRN
 * SkRSoIwl4SifJe1Ocxp7fXI4Av9ucEe+QyyQlETBdf6z3lqCkJ4P7DNip7FWzfSV
 * bop72SpsnF1hYaA3DinzBHCfjuKm0TcBfTamDzuR5uSUlrd3A+3J9fC+BxUMAuUN
 * ZvjTcGuRD2wvo29YUKk6e4sCUXpHd5z0EE/f7MmW8qOSwrFHsVZB/AacTC7dRZD7
 * twp59RWYedCdM+D4B26HOKMFC41q
 * -----END CERTIFICATE REQUEST-----
 * 打包修改类
 * @program: MyWebAppConfiguration
 *  www  8877
 * peixun 8077
 * @author: Kl
 * @create: 2019-12-31 11:48
 *
 * 生成好的证书串
 * -----BEGIN CERTIFICATE-----
 * MIIELjCCAxagAwIBAgIUHxlNRHlFYEbDwve1Ow5sEfAdpngwDQYJKoZIhvcNAQEL
 * BQAwXjELMAkGA1UEBhMCQ04xEzARBgNVBAoTClRlbnBheS5jb20xHTAbBgNVBAsT
 * FFRlbnBheS5jb20gQ0EgQ2VudGVyMRswGQYDVQQDExJUZW5wYXkuY29tIFJvb3Qg
 * Q0EwHhcNMjMwNDI1MDg1ODM5WhcNMjgwNDIzMDg1ODM5WjCBhzETMBEGA1UEAwwK
 * MTU3OTEyMDM4MTEbMBkGA1UECgwS5b6u5L+h5ZWG5oi357O757ufMTMwMQYDVQQL
 * DCrmuZbljZfph5HogYzkvJ/kuJrmr43lqbTmiqTnkIbmnInpmZDlhazlj7gxCzAJ
 * BgNVBAYMAkNOMREwDwYDVQQHDAhTaGVuWmhlbjCCASIwDQYJKoZIhvcNAQEBBQAD
 * ggEPADCCAQoCggEBAO/qS9fS7CFsGzF+eSl8S4SlX+KuI8Yl/+zEjd7S23U9LWBv
 * 6LeA6iefHIi3ByfgQrC9LlKnthLskBsEapBxBrme/SCEnufgWMX9ofCpS5/H+r+n
 * R4c8Oi5sLdgjemRpl9OfZEgD2LsR7hlflpf3aRczl2av4JIbk+BeV+tqjPUsqWL3
 * G7dByBPcT0jAXoUvusjT7LDwIs4a3dOU7KsFK9N9ExK4pSd2cls0ZKs92NTB8+VS
 * X7KWnQ5CtOdgthBnUL0R6nh3vvLz7d8K12MPDcn9JaHPgovTnv1yg4aGeArngoC4
 * pYiMivDMkMZ2P2rxPaHZEcT2PuVObg9SgJY9rO0CAwEAAaOBuTCBtjAJBgNVHRME
 * AjAAMAsGA1UdDwQEAwID+DCBmwYDVR0fBIGTMIGQMIGNoIGKoIGHhoGEaHR0cDov
 * L2V2Y2EuaXRydXMuY29tLmNuL3B1YmxpYy9pdHJ1c2NybD9DQT0xQkQ0MjIwRTUw
 * REJDMDRCMDZBRDM5NzU0OTg0NkMwMUMzRThFQkQyJnNnPUhBQ0M0NzFCNjU0MjJF
 * MTJCMjdBOUQzM0E4N0FEMUNERjU5MjZFMTQwMzcxMA0GCSqGSIb3DQEBCwUAA4IB
 * AQA/r5+tn2LwDCjzCPXrBlQxRwVZgIRC0qGV9dtiklZcqwTHTu+WtkqojBDlimek
 * ntREV1HP2sP6gpKim9hP5/ZYT7ES4KwVeVce6g6U4c+td+6UXlIWUz94FDAQXPRF
 * ZbcglXzuGw8m91F3ayG+UtX0s09FeEsBjCYPnd74GFEBYG324d70JyUEaDmFtMlk
 * RAddQcu3JK7Y6IorKB9WMkRgyxXZg2nda+BwA8+sg3BKJPc4a3hguWLgNRhAZa4b
 * Ft7t6Tm29Dq/qCAT2tOHVQ2iF3qkVKgCKZRSyzbdqNNFkhoeJ5hUgXq2x1H/VNXb
 * Eaiwc0Ea5wuH00UsK/fyQfcd
 * -----END CERTIFICATE-----
 **/
@Configuration
public class MyWebAppConfiguration extends WebMvcConfigurerAdapter {

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        //和页面有关的静态目录都放在项目的static目录下
        registry.addResourceHandler("/upload/**").addResourceLocations("classpath:/upload/");
        //上传的图片在D盘下的OTA目录下，访问路径如：http://127.0.0.1:8888/upload/20191231/f/b/aaa.jpeg
        //其中upload表示访问的前缀。"file:D:/Workspaces/web/upload/"是文件真实的存储路径(项目路径后）
        //本地
        registry.addResourceHandler("/upload/**").addResourceLocations("file:" + ValuesUtil.localUrl + "/upload/");
        //线上
        //registry.addResourceHandler("/upload/**").addResourceLocations("file:C:/Users/Administrator/Desktop/X-jinzhi/upload/");
    }

    @Override
    public void addViewControllers(ViewControllerRegistry registry) {
       registry.addViewController("/").setViewName("certificateWeb/homepage/homepage");//证书考试门户-8877,8899
//           registry.addViewController("/").setViewName("cultivateWeb/index");//培训就业门户-8077,8099
        registry.setOrder(Ordered.HIGHEST_PRECEDENCE);
        super.addViewControllers(registry);
    }
}


